
<?php use solideagle\utilities\SuperEntities; ?>

<script>
	$(function(){


		$('#myModal').modal('show');
		
		$("#lbldeletesure").hide();
                $("#alertRenameGroup").hide();

		$("#blnDelete").click(function(){
			$("#lbldeletesure").toggle();
			$("#blnDeleteSure").removeAttr("checked");
		});
	
		$("#groupbreadcrumbs").load("<?php echo $this->SE_path . '/groups/getgroupbreadcrumbs?groupid=' . $this->group->getId() ?>");
		
		$("#formEditGroup").ajaxForm({
			beforeSubmit:  preventDoubleSubmit,
			success: function(responseText, statusText, xhr, $form) { 

				if(responseText.length > 0)
				{
					alert(responseText);
					resetDoubleSubmit();
				}else{
					$('#myModal').modal('hide');
					updateTree();
				}
				
                } });
        
                $("#txtName").focusin(function() {
                           $("#alertRenameGroup").fadeIn();
                });
	});

</script>






<form class="form-horizontal" action="<?php echo $this->SE_path . "/groups/updategrouppost" ?>" method="post"
	id="formEditGroup">

	<div class="hide SEsupermodal" id="myModal">
		<div>
			<div class="modal-header">
				<a class="close" data-dismiss="modal">×</a>
				<h3 id="modaltitle">
					Groep bewerken<small id="groupbreadcrumbs"></small>
				</h3>
			</div>
			<div class="modal-body">

				<fieldset>


					<div class="control-group">
						<label class="control-label" for="txtName">Naam</label>
						<div class="controls">
							<input id="txtName" name="groupName" class="input-xlarge" type="text"
								value="<?php echo SuperEntities::encode($this->group->getName()); ?>">
						</div>
					</div>
                                    
                                        <div class="alert" id="alertRenameGroup">
						<strong>Opgelet!</strong> Een groep hernoemen zorgt voor extra manueel werk!
					</div>



					<div class="control-group">
						<label class="control-label" for="txtDescription">Omschrijving</label>
						<div class="controls">
							<textarea id="txtDescription" name="groupDescription" class="input-xlarge" rows="3"><?php echo SuperEntities::encode($this->group->getDescription()) ?></textarea>
						</div>
					</div>

					<div class="control-group">
						<label class="control-label" for="cbActive">Standaard Types</label>
						<div class="controls">
							<?php foreach($this->types as $type)
                                        {?>
							<label class="checkbox">
								<input name="ptype[]" value="<?php echo $type->getId(); ?>"
								<?php
								
								if(in_array($type,$this->group->getTypes()))
								{
									echo "checked='checked'";
								}
								?>
									type="checkbox">
								<?php echo $type->getTypeName(); ?>
							</label>
							<?php } ?>
						</div>
					</div>


					<div class="control-group">
						<label class="control-label" for="txtDescription">Verplaatsen</label>
						<div class="controls">
							<select name="selectGroup">
								<option value="ignore">Niet verplaatsen</option>
								<?php foreach($this->groups as $group)
								{
									if($group->getId() === $this->group->getId())
										continue;
									?>

								<option value="<?php echo $group->getId(); ?>">
									<?php echo SuperEntities::encode($group->getName()); ?>
								</option>

								<?php } ?>

							</select>
						</div>
					</div>


					<input type="hidden" name="groupid" value="<?php echo $this->group->getId() ?>">
				</fieldset>

			</div>
			<div class="modal-footer">
				<a href="#" class="btn" data-dismiss="modal">Annuleren</a>
				<button class="btn btn-primary" type="submit">Bijwerken</button>
			</div>
		</div>
	</div>

</form>
